import logging

from tinyops.library.config import SmtpNotifierConfig
from tinyops.library.json_helper import shorten_text

from .interface import INotifier


LOG = logging.getLogger(__name__)


class SMTPNotifier(INotifier):
    def __init__(self, config: SmtpNotifierConfig):
        self.name = config.name
        self.timeout = config.timeout

    def notify(self, title, content=None):
        LOG.info(f'notify title={title!r} content={shorten_text(content, 40)!r}')
        print('SMTP: ', title, content or '')

    def close(self):
        pass
